﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Elight.Service;
using Elight.Service.Interfaces;
using Elight.Repository;
using Elight.Repository.Interfaces;

namespace Elight.WebApi.Extensions
{
    /// <summary>
    /// 自定义服务配置相关扩展。
    /// </summary>
    public static class ServiceExtensions
    {
        /// <summary>
        /// 注册业务服务。
        /// </summary>
        /// <param name="services"></param>
        public static void RegisterServices(this IServiceCollection services)
        {
            services.AddScoped<IAccessService, AccessService>();
            services.AddScoped<IDepartmentService, DepartmentService>();
            services.AddScoped<IGeneralContentService, GeneralContentService>();
            services.AddScoped<IGeneralService, GeneralService>();
            services.AddScoped<ILogService, LogService>();
            services.AddScoped<IOrganizationService, OrganizationService>();
            services.AddScoped<IRoleAccessService, RoleAccessService>();
            services.AddScoped<IRoleService, RoleService>();
            services.AddScoped<IUserService, UserService>();
            services.AddScoped<IUserRoleService, UserRoleService>();
            services.AddScoped<IUserSigninService, UserSigninService>();
        }

        /// <summary>
        /// 注册仓储服务。
        /// </summary>
        /// <param name="services"></param>
        public static void RegisterRepositories(this IServiceCollection services)
        {
            services.AddScoped<IAccessRepository, AccessRepository>();
            services.AddScoped<IDepartmentRepository, DepartmentRepository>();
            services.AddScoped<IGeneralContentRepository, GeneralContentRepository>();
            services.AddScoped<IGeneralRepository, GeneralRepository>();
            services.AddScoped<ILogRepository, LogRepository>();
            services.AddScoped<IOrganizationRepository, OrganizationRepository>();
            services.AddScoped<IRoleAccessRepository, RoleAccessRepository>();
            services.AddScoped<IRoleRepository, RoleRepository>();
            services.AddScoped<IUserRepository, UserRepository>();
            services.AddScoped<IUserRoleRepository, UserRoleRepository>();
            services.AddScoped<IUserSigninRepository, UserSigninRepository>();
        }
    }
}
